﻿/**********************************************************************************
 * Description:     
 * MemberVariable:
 * Functions:       
 * Modify information:     
 * 2008-8-5     New           DuYaoHui     Create Class
 * 
 * ********************************************************************************/
using System;
using Fjaspx.Sys.Model;
using Fjaspx.Common;
namespace Fjaspx.UI.Web
{
    public partial class Administrator_config_config : AdminPage
    {
        /// <summary>
        /// 类
        /// </summary>
        ReadWriteConfig Config = new ReadWriteConfig();
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                Fjaspx.Sys.Model.ROYcmsConfig config = Fjaspx.Config.ROYcmsConfig.Get_Config();
                Config.ConfigType = (int)ConfigFileType.WebConfig;
                //基本
                TextBox_web_host.Text = config.web_host;
                TextBox_web_name.Text = config.web_name;
                TextBox_web_password.Text = config.password;
                TextBox_web_forge.Text = config.web_forge;
                TextBox_WEBSITE_UP_FILES.Text = config.WEBSITE_UP_FILES;
                TextBox_templet_language.Text = config.templet_language;
                TextBox_templet_root.Text = config.templet_root;
                TextBox_templet_file.Text = config.templet_file;
                //高级
                TextBox_GUID.Text = config.GUID;
                TextBox_UcenterWebserver.Text = config.UcenterWebserver;
                TextBox_UcenterPassword.Text = config.UcenterPassword;
                TextBox_logo.Text = config.logo;
                TextBox_title.Text = config.title;
                TextBox_keyword.Text = config.keyword;
                TextBox_Description.Text = config.Description;
                TextBox_Copyright.Text = config.Copyright;


                FileManager_root.Text = config.FileManager_root;
                FileManager_file_type.Text = config.FileManager_file_type;

                if (config.HTML_zip == "true")
                {
                    CheckBox2.Checked = true;
                }
                if (config.HTML == "true")
                {
                    CheckBox_HTML.Checked = true;
                }
            }
        }
        /// <summary>
        /// Handles the Click event of the Button_update control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Button_update_Click(object sender, EventArgs e)
        {
            //基本
            Config.ConfigType = (int)ConfigFileType.WebConfig;
            Config.modifyElement("web_name", TextBox_web_name.Text);
            Config.modifyElement("web_host", TextBox_web_host.Text);
            Config.modifyElement("password", TextBox_web_password.Text);
            Config.modifyElement("web_forge", TextBox_web_forge.Text);
            Config.modifyElement("WEBSITE_UP_FILES", TextBox_WEBSITE_UP_FILES.Text);
            Config.modifyElement("templet_language", TextBox_templet_language.Text);
            Config.modifyElement("templet_root", TextBox_templet_root.Text);
            Config.modifyElement("templet_file", TextBox_templet_file.Text);
            Config.modifyElement("FileManager_root", FileManager_root.Text);
            Config.modifyElement("FileManager_file_type", FileManager_file_type.Text);
            if (CheckBox2.Checked)
            {
                Config.modifyElement("HTML_zip", "true");
            }
            else { Config.modifyElement("HTML_zip", "false"); }
            if (CheckBox_HTML.Checked)
            {
                Config.modifyElement("HTML", "true");
            }
            else { Config.modifyElement("HTML", "false"); }


            //高级
            Config.modifyElement("GUID", TextBox_GUID.Text);
            Config.modifyElement("UcenterWebserver", TextBox_UcenterWebserver.Text);
            Config.modifyElement("UcenterPassword", TextBox_UcenterPassword.Text);
            Config.modifyElement("logo", TextBox_logo.Text);
            Config.modifyElement("title", TextBox_title.Text);
            Config.modifyElement("keyword", TextBox_keyword.Text);
            Config.modifyElement("Description", TextBox_Description.Text);
            Config.modifyElement("Copyright", TextBox_Copyright.Text);


            Response.Redirect("/administrator/Message.aspx?message=配置文件修改成功！&z=yes");
        }
    }
}